package bookticket.core.base;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.poi.ss.formula.functions.T;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;

public abstract class BaseController<T> {

	public abstract BaseService<T> getBaseService();
	
	@ResponseBody
	@RequestMapping("/findAll")
	public Map<String,Object> findAll(Integer page,Integer rows,String studentName){
		
		Integer before = (page-1)*rows;
		Integer after = rows;
		
		Map<String, Object> pageMap = new HashMap<String,Object>();
		pageMap.put("before", before);
		pageMap.put("after", after);
		
		List<T> list = getBaseService().findAll(pageMap);
		Map<String, Object> map = new HashMap<String,Object>();
		
		//分页查询中固定的写法  total rows
		int total = getBaseService().getTotalCounter();
		map.put("total", total);
		map.put("rows", list);
		map.put("result", "success");
		
		return map;
	}
	
	
}
